package com.bfly.mall.wechat.common;

import com.bfly.core.base.entity.RemoteResponse;
import com.bfly.core.enums.SysError;
import com.bfly.core.exception.ServiceResponseException;

/**
 * 微信返回结果验证
 *
 * @author 长沙商脉科技有限公司
 * @date 2020/5/9 16:40
 */
public class WeChatAssert {

    /**
     * 对微信支付v3 api结果检查
     *
     * @author 长沙商脉科技有限公司
     * @date 2020/5/9 16:52
     */
    public static void checkResponse(RemoteResponse response) {
        if (response == null) {
            throw new ServiceResponseException(SysError.ERROR, "结果为空!");
        }
        if (!response.isSuccessful()) {
            String result = response.getErrorCode().concat(":" + response.getErrorMsg());
            throw new ServiceResponseException(SysError.ERROR, result);
        }
    }
}
